package com.yugu.park.system.controller;

import java.util.Arrays;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
import com.yugu.park.system.entity.SysOperLogEntity;
import com.yugu.park.system.service.SysOperLogService;
import com.yugu.util.ResponseUtil;
import com.yugu.util.SearchPage;
import com.github.pagehelper.PageInfo;

/**
 * 操作日志记录
 *
 * @author guxf
 * @email sjzyug@163.com
 * @date 2023-08-22 11:57:05
 */
@Api(tags = {"操作日志记录"})
@RestController
@RequestMapping("system/sysoperlog")
public class SysOperLogController {
    @Autowired
    private SysOperLogService service;

    /**
     * 列表
     */

    @ApiOperation(value="分页查询", notes="分页查询")
    @RequestMapping(value = "/page", method = RequestMethod.POST)
    public ResponseUtil.Result<PageInfo<SysOperLogEntity>> page (@RequestBody SearchPage<SysOperLogEntity> search){
        PageInfo<SysOperLogEntity> page = service.page(search);
        return ResponseUtil.addSuccess(page);
    }
	@ApiOperation(value="查看详情", notes="查看详情")
    @GetMapping("/{id}")
    public ResponseUtil.Result<SysOperLogEntity> info(@PathVariable("id") String id){
		SysOperLogEntity sysOperLog = service.getById(id);
        return ResponseUtil.addSuccess(sysOperLog);
    }
    @ApiOperation(value="新增或修改", notes="新增或修改")
    @RequestMapping(value="/addOrUpdate", method= RequestMethod.POST)
    public ResponseUtil.Result<Boolean> save(@RequestBody SysOperLogEntity sysOperLog){
		service.addOrUpdate(sysOperLog);
        return ResponseUtil.addSuccess(true);
    }
    @ApiOperation(value="批量删除", notes="批量删除")
    @RequestMapping(value="/{id}", method = RequestMethod.DELETE)
    public ResponseUtil.Result<Boolean> delete(@PathVariable("id") String id){
    	service.removeByIds(Arrays.asList(id.split(",")));
        return ResponseUtil.addSuccess(true);
    }

}
